//
//  MenuScene.m
//  iAnimator
//
//  Created by 국현 경 on 09. 06. 01.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "MenuScene.h"
#import "StartScene.h"
@implementation MenuScene
- (id) init {
    self = [super init];
    if (self != nil) {
        Sprite * bg = [Sprite spriteWithFile:@"menu.png"];
        [bg setPosition:ccp(240, 160)];
        [self addChild:bg z:0];
        [self addChild:[MenuLayer node] z:1];
    }
    return self;
}
@end

@implementation MenuLayer
- (id) init {
    self = [super init];
    if (self != nil) {
        [MenuItemFont setFontSize:20];
        [MenuItemFont setFontName:@"Helvetica"];
        MenuItem *start = [MenuItemFont itemFromString:@"New Animation"
												target:self
											  selector:@selector(newAnimation:)];
	MenuItem *load = [MenuItemFont itemFromString:@"Load Animation"
												target:self
											  selector:@selector(loadAnimation:)];
        MenuItem *help = [MenuItemFont itemFromString:@"Help"
											   target:self
											 selector:@selector(help:)];
        Menu *menu = [Menu menuWithItems:start, load, help, nil];
        [menu alignItemsHorizontally];
        [self addChild:menu];
    }
    return self;
}

-(void)newAnimation: (id)sender {
	StartScene * ss = [StartScene node];
	[[Director sharedDirector] pushScene:ss];
//	[[Director sharedDirector] replaceScene:ss];
}

-(void)loadAnimation: (id)sender {
	StartScene * ss = [StartScene node];
	[[Director sharedDirector] replaceScene:ss];
}

-(void)help: (id)sender {
    NSLog(@"help");
}
@end